import React from "react";
import { Input, Typography } from "antd";
import {
  QuestionTextareaDefaultProps,
  QuestionTextareaPropsType,
} from "./interface";
import useQuestionPageType from "../../../../hooks/useQuestionPageType";
import { genFontSize } from "../../../../utils/common";
import commonStyles from "../common.module.scss";

const QuestionTextarea: React.FC<QuestionTextareaPropsType> = (
  props: QuestionTextareaPropsType
) => {
  const { title, placeholder, prompt } = {
    ...QuestionTextareaDefaultProps,
    ...props,
  };
  // 判断当前页面，如果是统计页则选中提示答案
  const { isStatPage } = useQuestionPageType();

  return (
    <div>
      <Typography.Title
        level={5}
        style={{
          fontSize: genFontSize(5),
        }}
        className={commonStyles.h5}
      >
        {title}
      </Typography.Title>
      <Input.TextArea
        autoSize={{ minRows: 5, maxRows: 8 }}
        placeholder={placeholder}
        value={isStatPage ? prompt : ""}
      />
    </div>
  );
};

export default QuestionTextarea;
